package offer;

import java.util.List;

public class TreeNode {
    int val;
    TreeNode left;
    TreeNode right;

    TreeNode() {
    }

    TreeNode(int val) {
        this.val = val;
    }

    TreeNode(int val, TreeNode left, TreeNode right) {
        this.val = val;
        this.left = left;
        this.right = right;
    }

    public String toString() {
        return TreeUtil.toList(this).toString();
    }

    TreeNode(List<Integer> tree) {
        TreeNode t = TreeUtil.toTree(tree);
        if (t != null) {
            this.val = t.val;
            this.left = t.left;
            this.right = t.right;
        }
    }
}
